package com.kly.user.task.enums;

import java.util.Objects;

/**
 * @author linqu
 */
public enum TaskTypeEnum {
    /**
     * 超过指定时限，wlm重回陌生人池
     */
    WLM_RESET(1, "WHO_LIKE_ME", null, 60, 1),
    /**
     * 自动wlm推送任务
     */
    PUSH_WLM(2, "PUSH_WLM", null, 60, 1),
    /**
     * 自动likes back任务Å
     */
    LIKES_BACK(3, "LIKES_BACK", null, 60, 1),
    /**
     * 消息推送
     */
    NOTICE_PUSH(4, "NOTICE_PUSH", null, 180, 1),
    /**
     * push消息定时推送
     */
    APP_MESSAGE_PUSH(5, "APP_MESSAGE_PUSH", null, 60, 1),

    /**
     * 统计数据
     */
    STATISTICAL(6, "STATISTICAL", null, 60*30, 1),

    /**
     * 推送统计数据到appsFlyer
     */
    PUSH_DATA_TO_APPSFLYER(7, "PUSH_DATA_TO_APPSFLYER", null, 60*60, 1),

    /**
     * 推送统计数据到appsFlyer
     */
    PUSH_DATA_TO_APPSFLYER_V2(13, "PUSH_DATA_TO_APPSFLYER_V2", null, 60*60, 1),
    /**
     * 推送统计数据到adjust
     */
    PUSH_DATA_TO_AD_JUST(14, "PUSH_DATA_TO_AD_JUST", null, 60*60, 1),

    /**
     * 日志清理
     */
    REMOVE_LOG(999, "REMOVE_LOG", null, 60, 2),

    /**
     * 推送统计数据到adjust
     */
    PUSH_DATA_TO_AD_JUST_V2(15, "PUSH_DATA_TO_AD_JUST_V2", null, 60*60, 1),

    /**
     * 推送统计数据到appsFlyer
     */
    PUSH_DATA_TO_FIREBASE_V1(16, "PUSH_DATA_TO_FIREBASE_V1", null, 60 * 60, 1),
    ;


    private Integer code;

    private String name;
    /**
     * 任务可执行的最大次数限制, maxExecuteTimes表示无限循环任务
     */
    private Integer maxExecuteTimes;
    /**
     * 下次任务执行的时间间隔， 单位：秒
     */
    private Integer reTryTimeLength;
    /**
     * 任务类型：1-固定频率 2-指定时间执行
     */
    private Integer taskPeriod ;


    TaskTypeEnum(Integer code, String name, Integer maxExecuteTimes, Integer reTryTimeLength, Integer taskPeriod) {
        this.code = code;
        this.name = name;
        this.maxExecuteTimes = maxExecuteTimes;
        this.reTryTimeLength = reTryTimeLength;
        this.taskPeriod = taskPeriod;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getMaxExecuteTimes() {
        return maxExecuteTimes;
    }

    public void setMaxExecuteTimes(Integer maxExecuteTimes) {
        this.maxExecuteTimes = maxExecuteTimes;
    }

    public Integer getReTryTimeLength() {
        return reTryTimeLength;
    }

    public void setReTryTimeLength(Integer reTryTimeLength) {
        this.reTryTimeLength = reTryTimeLength;
    }

    public Integer getTaskPeriod() {
        return taskPeriod;
    }

    public void setTaskPeriod(Integer taskPeriod) {
        this.taskPeriod = taskPeriod;
    }

    public static TaskTypeEnum getEnumByCode(Integer code) {

        if (Objects.isNull(code)) {
            return null;
        }

        TaskTypeEnum TaskTypeEnum = null;

        for (TaskTypeEnum p : com.kly.user.task.enums.TaskTypeEnum.values()) {
            if (p.getCode().equals(code)) {
                TaskTypeEnum = p;
            }
        }
        return TaskTypeEnum;
    }

}
